var env = {
	contextPath : ""
};

function setContextPath(paramContextPath){
	env.contextPath = paramContextPath;
}



$().ajaxStop($.unblockUI); 
$().ajaxError($.unblockUI); 
$().ajaxSuccess($.unblockUI); 

$.ajaxSetup({
	global: true,
    beforeSend: function(xhr) { 
		$.blockUI({ message: '<h4>잠시만 기다려 주세요.</h4>' });  
	} ,
	success: function(data) {
		$.unblockUI();
	}
});	

$.postJSON = function(url, data, callback) {
	$.post(url, data, callback, "json");
};

$.postRequest = function(url, param, callback) {
	$.post(url, param, callback, "html");
};

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}

String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

String.prototype.replaceAll = function(str1, str2){
	var temp_str = "";
	if (this.trim() != "" && str1 != str2){
		temp_str = this.trim();
		
		while (temp_str.indexOf(str1) > -1){
			temp_str = temp_str.replace(str1, str2);
		}
	}
	return temp_str;
}


function isNull(str){
	if(str == null) return true;
	return !(str.replace(/(^\s*)|(\s*$)/g, ""));
}

function getIEVer(){
	var retval = 0;
    var agent = navigator.userAgent.toLowerCase();
    var ver = agent.split(';');
    if(agent.indexOf('msie') != -1){
        retval = parseFloat(ver[1].slice(6, ver[1].length));
	}
	return retval;
}

function getMousePosition(event){
	var x = (getIEVer()<=0) ? event.pageX: window.event.clientX + document.documentElement.scrollLeft;
	var y = (getIEVer()<=0) ? event.pageY: window.event.clientY + document.documentElement.scrollTop;		
	return {"x":x,"y":y};
}

function setVisibleObject(flag, objectId, event){
    var tempObject = $("#"+objectId);
	if(flag){
		if(event){
			var pos = getMousePosition(event);
			var tempCss = {		
				top: pos.y + 5,
				left: pos.x + 5
			};
			tempObject.css(tempCss);
		}
		tempObject.show();	
	}else{
		tempObject.hide();
	}	
}